package 常用类.Array类.set.treeSet;


import 常用类.Array类.set.User;

import java.util.Comparator;
import java.util.TreeSet;

public class TreeSet1 {
    public static void main(String[] args) {
        TreeSet<User> ts=new TreeSet<>(new Comparator<User>() {
            @Override
            public int compare(User user1, User user2) {
                return user2.getUserId()-user1.getUserId();
            }
        });
        TreeSet<User> treeSet=new TreeSet<User>();
        User user1 = new User(1,"admin1");
        User user2 = new User(2,"admin2");
        User user3 = new User(3,"admin3");
        treeSet.add(user1);
        treeSet.add(user2);
        treeSet.add(user3);
        for (User user:treeSet){
            System.out.println(user);
        }
    }
}
